package com.muyi.biling.di;

import android.app.Application;

import com.muyi.biling.DaggerMyAppComponent;
import com.muyi.biling.MyAppComponent;
import com.muyi.biling.fragment.more.DaggerShopSettingFragmentComponent;
import com.muyi.biling.fragment.more.ShopSettingFragmentComponent;
import com.muyi.biling.ui.DaggerMainActivityComponent;
import com.muyi.biling.ui.DaggerOrderEditActivityComponent;
import com.muyi.biling.ui.MainActivityComponent;
import com.muyi.biling.ui.OrderEditActivityComponent;

/**
 * Created by developer on 18-1-24.
 */

public class Injector {

    private static MyAppComponent mAppComponent = null;

    private Injector() {}
    public static MyAppComponent initMyAppComponent(Application app) {
        mAppComponent = null;
        mAppComponent = DaggerMyAppComponent.builder()
                .appModule(new AppModule(app))
                .build();
        return mAppComponent;
    }

    public static MainActivityComponent initMainActivityComponent() {
        MainActivityComponent component = null;
        if (mAppComponent != null) {
            component = DaggerMainActivityComponent.builder()
                    .myAppComponent(mAppComponent)
                    .build();
        }
        return component;
    }

    public static OrderEditActivityComponent initOrderEditActivityComponent() {
        OrderEditActivityComponent component = null;
        if (mAppComponent != null) {
            component = DaggerOrderEditActivityComponent.builder()
                    .myAppComponent(mAppComponent)
                    .build();
        }
        return component;
    }

    public static ShopSettingFragmentComponent initShopSettingFragmentComponent() {
        ShopSettingFragmentComponent component = null;
        if (mAppComponent != null) {
            component = DaggerShopSettingFragmentComponent.builder()
                    .myAppComponent(mAppComponent)
                    .build();
        }
        return component;
    }

}
